package com.chentf.a01_beanfactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @author chentengfei
 * @desc ...
 * @date 2023-03-22 14:02:50
 */
@Component
public class Component01 {

    private static final Logger log = LoggerFactory.getLogger(Component01.class);

    // 事件发布器-发送事件功能
    @Autowired
    private ApplicationEventPublisher context;

    public void register() {
        log.debug("用户注册");
        // 发送UserRegisteredEvent事件
        context.publishEvent(new UserRegisteredEvent(this));
    }
}
